define(["jquery","bbcare",
	"comm/datatable/datatable",
    "bch/app/visit/visitAppointList.servers",
    "bch/app/visit/visitAppointList.ui"],
    function($,$bb,$datatable,$servers,$ui){
	var visitAppointList = {};

	/**
     * 点击添加
     */
    var onAddRecord = function(){
        var params = $bb.getPageParams();
        var domId = $(this).attr("id");
        $bb.open(params,domId,"bch_visitAppointAdd",{"status":"04"}); // "04":新增
    }

    /**
     * 今日访视家庭提醒
     */
    var ajaxRemindPatientRecordCallBack = function(data){
        if( data.rows.length > 0 ){
            $ui.warn({
                "id":"visitWarnTodayBox",
                "list":data.rows
            });
        }else{
            $("#visitWarnToday").remove();
        }
    }

    visitAppointList.init = function(){
        // 添加患者
        $("#addBtn").unbind("click");
        $("#addBtn").click(onAddRecord);
        //今日访视家庭提醒
        $servers.ajaxRemindPatientRecord(ajaxRemindPatientRecordCallBack);
        // datatable
        var id = $(".layout-bottom table").attr("id");
        $datatable.init({
            "id": id,
            "options": $servers.getOptions()
        });
    }

	return visitAppointList;
});